﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class SimpleFlyOut : FadeOutBase {

    MeshRenderer render;

    private void Awake()
    {
        render = GetComponentInChildren<MeshRenderer>();
    }

    void Start () {

        //scale
        transform.DOScale(0.2f, 1f);
        transform.DOMove(new Vector3(transform.position.x + 4.5f, transform.position.y + 3f, transform.position.z), 0.5f);

        Color temColor = render.material.color;
        Tweener tweener = DOTween.ToAlpha(() => temColor, x => temColor = x, 0f, 0.5f);
        tweener.OnUpdate(() => { render.material.color = temColor; });
        tweener.OnComplete(() => {
            GameObject.Destroy(gameObject);
        });
    }
	
	void Update () {
		
	}
}
